<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报单明细</title>
<link href="<?php echo $_BASE_DIR?>css_v1/style.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $_BASE_DIR?>css_v1/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $_BASE_DIR?>js_v1/jquery.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR?>js_v1/jmw.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR?>js_v1/select-ui.min.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR?>js_v1/jquery.DatePicker.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
		width : 345			  
	});
	$(".select2").uedSelect({
		width : 167  
	});
	$(".select3").uedSelect({
		width : 110
	});
});
</script>



</head>
<?php
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$output = $base_url;
$output['action'] = 'output';

?>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
  <li><a href="<?php echo url("leftmenu/bottom")?>">首页</a></li>
    <li><a href="#">积分明细</a></li>
  
    </ul>
    </div>
    
    <div class="rightinfo">
	
	
<!--------------------------------------->
	
	<div style=" width:99%;height:35px; border:1px #fff solid; line-height:35px; margin-bottom:5px;">
	<form method="post" action="<?php echo url("finance/index") ?>">
	<div class="tabsongm" >
    <ul class="seachform">
    
			 <li><label>日期：</label><input name="day_begin" id="day_begin" value="<?php echo isset($param['day_begin'])?$param['day_begin']:'';?>" type="text" class="scinputjmw" />---<input name="day_end" id="day_end" value="<?php echo isset($param['day_end'])?$param['day_end']:'';?>" type="text" class="scinputjmw" /></li>  
			 
		<li><label>&nbsp;</label><input type="submit" class="scbtn" value="查询" style="width:60px;"/></li>
	</ul>
	</div>

	</form>
	
	
	</div>
	
	    <div style="clear: both;width:97%;height:60px;line-height:25px;margin: 10px 10px 0px 20px;color: red">
       	<?php 
	     
	    $sql = ($_SESSION['lastsql']);
        $obj = call_user_func_array(array(finance::meta(),'find'), $sql);
        $data = $obj->asArray()->getAll();
        $totalsale = 0;
        $totalfx = 0;
        $yitixian = 0;
        $weitixian = 0;
       
        if(count($data)){
            foreach ($data as $v){
                $totalsale += $v['total_sale'];
                $totalfx += $v['user_rewardsale'];
                $yitixian += $v['user_totalwithdraw'];
                $weitixian += $v['user_unwithdraw'];
               
            }
        }
        $lirun = $totalsale - $totalfx;
	    ?>
        <?php echo "查询时间段累计销售额： {$totalsale}元，累计分佣出去总额 {$totalfx} 元，累计已提现 {$yitixian} 元，累计未提现 {$weitixian} 元，累计净利润 {$lirun} 元"; ?>

    </div>
        <div class="tools">
    
    
           <li><input onclick="downuser();" type="button" class="scbtn" value="导出查询结果" style="width:110px;margin-top:-10px;"/></li>

    </div>
    
	<!---------------------------------------------------- --> 	
 <script>
	$('#day_begin').datePicker({followOffset : [0, 24]});
	$('#day_end').datePicker({followOffset : [0, 24]});
	</script>
 <table class="tablelist">

    	<thead>
    	<tr>
    	          <th width="10%" >日期</th>
              <th width="10%"  >销售额</th>
               <th width="10%"  >分佣出去金额</th>
        		<th width="10%" >已提现金额</th>
				 <th width="10%"  >未提现金额</th>
	            <th width="15%" >净利润</th>
				
        </tr>
        </thead>
        <tbody>
        <?php foreach($item as $k=>$v):?>
        <tr>
        	<td><?php echo $v->day?></td>
				<td><?php echo h($v->total_sale);
				?></td>
			
				<td><?php echo h($v->user_rewardsale)?></td>
				<td><?php echo h($v->user_totalwithdraw)?></td>
				<td><?php echo h($v->user_unwithdraw)?></td>
				<td><?php echo ($v->total_sale - $v->user_rewardsale)?></td>
        </tr> 
	   <?php endforeach;?>
        </tbody>
    </table>
    
    <?php echo Q::control('pagination','pagination',array('url_args'=>$param,'pagination'=>$pagination,'show_count'=>1))?>
    
    

    
    </div>
    
    <script type="text/javascript">
    function downuser()
    {
        document.getElementById("output1").src='<?php echo url($output)?>';

    }
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>

</body>
<iframe width="0" height="0" id="output1" name="output1" ></iframe>
</html>

